package com.vpa.main;

import java.util.HashMap;



public class PID_Store {
	
	final int NUM_PIDS = 141;

	String[] gauge_labels;
	double[] max_val;
	double[] min_val;
	boolean[] dynamic;
	public HashMap<Integer, PID_Entry> pid_map = new HashMap<Integer,PID_Entry>();

	
	public PID_Store(){
		populate_hashmap();
	}
	
	private void populate_hashmap(){
		
		/* AUTO GENERATERATED */
//		pid_map.put(0x0, new PID_Entry(0x0,"PIDs supported [01 - 20]",-1,-1,false));
//		pid_map.put(0x1, new PID_Entry(0x1,"Monitor status since DTCs cleared",-1,-1,false));
//		pid_map.put(0x2, new PID_Entry(0x2,"Freeze DTC",-1,-1,false));
		pid_map.put(0x3, new PID_Entry(0x3,"Fuel system status",-1,-1,false,""));
		pid_map.put(0x4, new PID_Entry(0x4,"Calculated engine load value",0,100,true,"%"));
		pid_map.put(0x5, new PID_Entry(0x5,"Engine coolant temperature",-40,215,true,"Deg. C"));
//		pid_map.put(0x6, new PID_Entry(0x6,"Short term fuel % trim�Bank 1",-100 ,99.22 ,true));
//		pid_map.put(0x7, new PID_Entry(0x7,"Long term fuel % trim�Bank 1",-100 ,99.22 ,true));
//		pid_map.put(0x8, new PID_Entry(0x8,"Short term fuel % trim�Bank 2",-100 ,99.22,true));
//		pid_map.put(0x9, new PID_Entry(0x9,"Long term fuel % trim�Bank 2",-100 ,99.22 ,true));
		pid_map.put(0x0A, new PID_Entry(0x0A,"Fuel pressure",0,765,true,"kPa"));
		pid_map.put(0x0B, new PID_Entry(0x0B,"Intake manifold absolute pressure",0,255,true,"kPa"));
		pid_map.put(0x0C, new PID_Entry(0x0C,"Engine RPM",0,16383.75,true,"rpm"));
		pid_map.put(0x0D, new PID_Entry(0x0D,"Vehicle speed",0,255,true,"km/h"));
		pid_map.put(0x0E, new PID_Entry(0x0E,"Timing advance",-64,63.5,true,"Deg. relative to #1 cylinder"));
		pid_map.put(0x0F, new PID_Entry(0x0F,"Intake air temperature",-40,215,true,"Deg. C"));
		pid_map.put(0x10, new PID_Entry(0x10,"MAF air flow rate",0,655.35,true,"grams/sec"));
		pid_map.put(0x11, new PID_Entry(0x11,"Throttle position",0,100,true,"%"));
		pid_map.put(0x12, new PID_Entry(0x12,"Commanded secondary air status",-1,-1,false,""));
		pid_map.put(0x13, new PID_Entry(0x13,"Oxygen sensors present",-1,-1,false,""));
//		pid_map.put(0x14, new PID_Entry(0x14,"Bank 1, Sensor 1: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x15, new PID_Entry(0x15,"Bank 1, Sensor 2: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x16, new PID_Entry(0x16,"Bank 1, Sensor 3: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x17, new PID_Entry(0x17,"Bank 1, Sensor 4: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x18, new PID_Entry(0x18,"Bank 2, Sensor 1: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x19, new PID_Entry(0x19,"Bank 2, Sensor 2: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x1A, new PID_Entry(0x1A,"Bank 2, Sensor 3: Oxygen sensor voltage",0,1.275,true));
//		pid_map.put(0x1B, new PID_Entry(0x1B,"Bank 2, Sensor 4: Oxygen sensor voltage",0,1.275,true));
/*<<<<<<< .mine
		pid_map.put(0x1C, new PID_Entry(0x1C,"OBD standards this vehicle conforms to",-1,-1,false,""));
		pid_map.put(0x1D, new PID_Entry(0x1D,"Oxygen sensors present",-1,-1,false,""));
		pid_map.put(0x1E, new PID_Entry(0x1E,"Auxiliary input status",-1,-1,false,""));
		pid_map.put(0x1F, new PID_Entry(0x1F,"Run time since engine start",0,65535,true,"seconds"));
=======
		pid_map.put(0x1C, new PID_Entry(0x1C,"OBD standards this vehicle conforms to",-1,-1,false));
//	pid_map.put(0x1D, new PID_Entry(0x1D,"Oxygen sensors present",-1,-1,false));
		pid_map.put(0x1E, new PID_Entry(0x1E,"Auxiliary input status",-1,-1,false));
		pid_map.put(0x1F, new PID_Entry(0x1F,"Run time since engine start",0,65535,true));
>>>>>>> .r61*/
//		pid_map.put(0x20, new PID_Entry(0x20,"PIDs supported [21 - 40]",-1,-1,false));
//		pid_map.put(0x21, new PID_Entry(0x21,"Distance traveled with malfunction indicator lamp (MIL) on",0,65535,true));
		pid_map.put(0x22, new PID_Entry(0x22,"Fuel Rail Pressure",0,5177.265,true,"kPa"));
		pid_map.put(0x23, new PID_Entry(0x23,"Fuel Rail Pressure",0,655350,true,"kPa"));
//		pid_map.put(0x24, new PID_Entry(0x24,"O2S1_WR_lambda(1):Voltage",0,7.999,true));
//		pid_map.put(0x25, new PID_Entry(0x25,"O2S2_WR_lambda(1):Voltage",0,8,true));
//		pid_map.put(0x26, new PID_Entry(0x26,"O2S3_WR_lambda(1):Voltage",0,8,true));
//		pid_map.put(0x27, new PID_Entry(0x27,"O2S4_WR_lambda(1):Voltage",0,8,true));
//		pid_map.put(0x28, new PID_Entry(0x28,"O2S5_WR_lambda(1):Voltage",0,8,true));
//		pid_map.put(0x29, new PID_Entry(0x29,"O2S6_WR_lambda(1):Voltage",0,8,true));
//		pid_map.put(0x2A, new PID_Entry(0x2A,"O2S7_WR_lambda(1):Voltage",0,8,true));
//		pid_map.put(0x2B, new PID_Entry(0x2B,"O2S8_WR_lambda(1):Voltage",0,8,true));
		pid_map.put(0x2C, new PID_Entry(0x2C,"Commanded EGR",0,100,true,"%"));
		pid_map.put(0x2D, new PID_Entry(0x2D,"EGR Error",-100,99.22,true,"%"));
		pid_map.put(0x2E, new PID_Entry(0x2E,"Commanded evaporative purge",0,100,true,"%"));
		pid_map.put(0x2F, new PID_Entry(0x2F,"Fuel Level Input",0,100,true,"%"));
//		pid_map.put(0x30, new PID_Entry(0x30,"# of warm-ups since codes cleared",0,255,true));
		pid_map.put(0x31, new PID_Entry(0x31,"Distance traveled since codes cleared",0,65535,true,"km"));
		pid_map.put(0x32, new PID_Entry(0x32,"Evap. System Vapor Pressure",-8192,8192,true,"Pa"));
		pid_map.put(0x33, new PID_Entry(0x33,"Barometric pressure",0,255,true,"kPa"));	
//		pid_map.put(0x34, new PID_Entry(0x34,"O2S1_WR_lambda(1):Current",-128,127.99,true));
//		pid_map.put(0x35, new PID_Entry(0x35,"O2S2_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x36, new PID_Entry(0x36,"O2S3_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x37, new PID_Entry(0x37,"O2S4_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x38, new PID_Entry(0x38,"O2S5_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x39, new PID_Entry(0x39,"O2S6_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x3A, new PID_Entry(0x3A,"O2S7_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x3B, new PID_Entry(0x3B,"O2S8_WR_lambda(1):Current",-128,128,true));
//		pid_map.put(0x3C, new PID_Entry(0x3C,"Catalyst Temperature Bank 1, Sensor 1",-40,6513.5,true));
//		pid_map.put(0x3D, new PID_Entry(0x3D,"Catalyst Temperature Bank 2, Sensor 1",-40,6513.5,true));
//		pid_map.put(0x3E, new PID_Entry(0x3E,"Catalyst Temperature Bank 1, Sensor 2",-40,6513.5,true));
//		pid_map.put(0x3F, new PID_Entry(0x3F,"Catalyst Temperature Bank 2, Sensor 2",-40,6513.5,true));
//		pid_map.put(0x40, new PID_Entry(0x40,"PIDs supported [41 - 60]",-1,-1,false));
		pid_map.put(0x41, new PID_Entry(0x41,"Monitor status this drive cycle",-1,-1,false,""));
		pid_map.put(0x42, new PID_Entry(0x42,"Control module voltage",0,65.535,true,"V"));
		pid_map.put(0x43, new PID_Entry(0x43,"Absolute load value",0,25700,true,"%"));
		pid_map.put(0x44, new PID_Entry(0x44,"Command equivalence ratio",0,2,true,"N/A"));
		pid_map.put(0x45, new PID_Entry(0x45,"Relative throttle position",0,100,true,"%"));
		pid_map.put(0x46, new PID_Entry(0x46,"Ambient air temperature",-40,215,true,"Deg. C"));
		pid_map.put(0x47, new PID_Entry(0x47,"Absolute throttle position B",0,100,true,"%"));
		pid_map.put(0x48, new PID_Entry(0x48,"Absolute throttle position C",0,100,true,"%"));
		pid_map.put(0x49, new PID_Entry(0x49,"Accelerator pedal position D",0,100,true,"%"));
		pid_map.put(0x4A, new PID_Entry(0x4A,"Accelerator pedal position E",0,100,true,"%"));
		pid_map.put(0x4B, new PID_Entry(0x4B,"Accelerator pedal position F",0,100,true,"%"));
		pid_map.put(0x4C, new PID_Entry(0x4C,"Commanded throttle actuator",0,100,true,"%"));
//		pid_map.put(0x4D, new PID_Entry(0x4D,"Time run with MIL on",0,65535,true));
		pid_map.put(0x4E, new PID_Entry(0x4E,"Time since trouble codes cleared",0,65535,true,"minutes"));
		//pid_map.put(0x4F, new PID_Entry(0x4F,"Maximum value for equivalence ratio, oxygen sensor voltage, oxygen sensor current, and intake manifold absolute pressure",0, 0, 0, 0,255, 255, 255, 2550,true));
		pid_map.put(0x50, new PID_Entry(0x50,"Maximum value for air flow rate from mass air flow sensor",0,2550,true,"g/s"));
		pid_map.put(0x51, new PID_Entry(0x51,"Fuel Type",-1,-1,false,""));
		pid_map.put(0x52, new PID_Entry(0x52,"Ethanol fuel %",0,100,true,"%"));
		pid_map.put(0x53, new PID_Entry(0x53,"Absolute Evap system Vapor Pressure",0,327.675,true,"kPa"));
		pid_map.put(0x54, new PID_Entry(0x54,"Evap system vapor pressure",-32767,32768,true,"Pa"));
//		pid_map.put(0x55, new PID_Entry(0x55,"Short term secondary oxygen sensor trim bank 1 and bank 3",-100,99.22,true));
//		pid_map.put(0x56, new PID_Entry(0x56,"Long term secondary oxygen sensor trim bank 1 and bank 3",-100,99.22,true));
//		pid_map.put(0x57, new PID_Entry(0x57,"Short term secondary oxygen sensor trim bank 2 and bank 4",-100,99.22,true));
//		pid_map.put(0x58, new PID_Entry(0x58,"Long term secondary oxygen sensor trim bank 2 and bank 4",-100,99.22,true));
		pid_map.put(0x59, new PID_Entry(0x59,"Fuel rail pressure (absolute)",0,655350,true,"kPa"));
		pid_map.put(0x5A, new PID_Entry(0x5A,"Relative accelerator pedal position",0,100,true,"%"));
		pid_map.put(0x5B, new PID_Entry(0x5B,"Hybrid battery pack remaining life",0,100,true,"%"));
		pid_map.put(0x5C, new PID_Entry(0x5C,"Engine oil temperature",-40,210,true,"Deg. C"));
		pid_map.put(0x5D, new PID_Entry(0x5D,"Fuel injection timing",-210,301.992,true,"Deg."));
		pid_map.put(0x5E, new PID_Entry(0x5E,"Engine fuel rate",0,3212.75,true,"L/h"));
		pid_map.put(0x5F, new PID_Entry(0x5F,"Emission requirements to which vehicle is designed",-1,-1,false,""));
//		pid_map.put(0x60, new PID_Entry(0x60,"PIDs supported [61 - 80]",-1,-1,false));
		pid_map.put(0x61, new PID_Entry(0x61,"Driver's demand engine - percent torque",-125,125,true,"%"));
		pid_map.put(0x62, new PID_Entry(0x62,"Actual engine - percent torque",-125,125,true,"%"));
		pid_map.put(0x63, new PID_Entry(0x63,"Engine reference torque",0,65535,true,"Nm"));
		pid_map.put(0x64, new PID_Entry(0x64,"Engine percent torque data",-125,125,true,"%"));
//		pid_map.put(0x65, new PID_Entry(0x65,"Auxiliary input / output supported",-1,-1,false));
		pid_map.put(0x66, new PID_Entry(0x66,"Mass air flow sensor",-1,-1,false,""));
		pid_map.put(0x67, new PID_Entry(0x67,"Engine coolant temperature",-1,-1,false,""));
		pid_map.put(0x68, new PID_Entry(0x68,"Intake air temperature sensor",-1,-1,false,""));
//		pid_map.put(0x69, new PID_Entry(0x69,"Commanded EGR and EGR Error",-1,-1,false));
//		pid_map.put(0x6A, new PID_Entry(0x6A,"Commanded Diesel intake air flow control and relative intake air flow position",-1,-1,false));
//		pid_map.put(0x6B, new PID_Entry(0x6B,"Exhaust gas recirculation temperature",-1,-1,false));
//		pid_map.put(0x6C, new PID_Entry(0x6C,"Commanded throttle actuator control and relative throttle position",-1,-1,false));
		pid_map.put(0x6D, new PID_Entry(0x6D,"Fuel pressure control system",-1,-1,false,""));
		pid_map.put(0x6E, new PID_Entry(0x6E,"Injection pressure control system",-1,-1,false,""));
//		pid_map.put(0x6F, new PID_Entry(0x6F,"Turbocharger compressor inlet pressure",-1,-1,false));
		pid_map.put(0x70, new PID_Entry(0x70,"Boost pressure control",-1,-1,false,""));
//		pid_map.put(0x71, new PID_Entry(0x71,"Variable Geometry turbo (VGT) control",-1,-1,false));
		pid_map.put(0x72, new PID_Entry(0x72,"Wastegate control",-1,-1,false,""));
		pid_map.put(0x73, new PID_Entry(0x73,"Exhaust pressure",-1,-1,false,""));
		pid_map.put(0x74, new PID_Entry(0x74,"Turbocharger RPM",-1,-1,false,""));
		pid_map.put(0x75, new PID_Entry(0x75,"Turbocharger temperature",-1,-1,false,""));
//		pid_map.put(0x76, new PID_Entry(0x76,"Turbocharger temperature",-1,-1,false));
//		pid_map.put(0x77, new PID_Entry(0x77,"Charge air cooler temperature (CACT)",-1,-1,false));
//		pid_map.put(0x78, new PID_Entry(0x78,"Exhaust Gas temperature (EGT) Bank 1",-1,-1,false));
//		pid_map.put(0x79, new PID_Entry(0x79,"Exhaust Gas temperature (EGT) Bank 2",-1,-1,false));
//		pid_map.put(0x7A, new PID_Entry(0x7A,"Diesel particulate filter (DPF)",-1,-1,false));
//		pid_map.put(0x7B, new PID_Entry(0x7B,"Diesel particulate filter (DPF)",-1,-1,false));
//		pid_map.put(0x7C, new PID_Entry(0x7C,"Diesel Particulate filter (DPF) temperature",-1,-1,false));
//		pid_map.put(0x7D, new PID_Entry(0x7D,"NOx NTE control area status",-1,-1,false));
//		pid_map.put(0x7E, new PID_Entry(0x7E,"PM NTE control area status",-1,-1,false));
		pid_map.put(0x7F, new PID_Entry(0x7F,"Engine run time",-1,-1,false,""));
//		pid_map.put(0x80, new PID_Entry(0x80,"PIDs supported [81 - A0]",-1,-1,false));
//		pid_map.put(0x81, new PID_Entry(0x81,"Engine run time for Auxiliary Emissions Control Device(AECD)",-1,-1,false));
//		pid_map.put(0x82, new PID_Entry(0x82,"Engine run time for Auxiliary Emissions Control Device(AECD)",-1,-1,false));
//		pid_map.put(0x83, new PID_Entry(0x83,"NOx sensor",-1,-1,false));
//		pid_map.put(0x84, new PID_Entry(0x84,"Manifold surface temperature",-1,-1,false));
//		pid_map.put(0x85, new PID_Entry(0x85,"NOx reagent system",-1,-1,false));
		pid_map.put(0x86, new PID_Entry(0x86,"Particulate matter (PM) sensor",-1,-1,false,""));
		pid_map.put(0x87, new PID_Entry(0x87,"Intake manifold absolute pressure",-1,-1,false,""));
//		pid_map.put(0xA0, new PID_Entry(0xA0,"PIDs supported [A1 - C0]",-1,-1,false));
//		pid_map.put(0xC0, new PID_Entry(0xC0,"PIDs supported [C1 - E0]",-1,-1,false));
//		pid_map.put(0xC3, new PID_Entry(0xC3,"?",?,?,true));
//		pid_map.put(0xC4, new PID_Entry(0xC4,"?",?,?,true));
//		pid_map.put(0x2, new PID_Entry(0x2,"Freeze frame trouble code",-1,-1,false));
		
		//**** NOT SUPPORTED ****//
//		pid_map.put(0xN/A, new PID_Entry(0xN/A,"Request trouble codes",-1,-1,false));
//		pid_map.put(0xN/A, new PID_Entry(0xN/A,"Clear trouble codes / Malfunction indicator lamp (MIL) / Check engine light",-1,-1,false));
//		pid_map.put(0x100, new PID_Entry(0x100,"OBD Monitor IDs supported ($01 � $20)",-1,-1,false));
//		pid_map.put(0x101, new PID_Entry(0x101,"O2 Sensor Monitor Bank 1 Sensor 1",0,1.275,true));
//		pid_map.put(0x102, new PID_Entry(0x102,"O2 Sensor Monitor Bank 1 Sensor 2",0,1.275,true));
//		pid_map.put(0x103, new PID_Entry(0x103,"O2 Sensor Monitor Bank 1 Sensor 3",0,1.275,true));
//		pid_map.put(0x104, new PID_Entry(0x104,"O2 Sensor Monitor Bank 1 Sensor 4",0,1.275,true));
//		pid_map.put(0x105, new PID_Entry(0x105,"O2 Sensor Monitor Bank 2 Sensor 1",0,1.275,true));
//		pid_map.put(0x106, new PID_Entry(0x106,"O2 Sensor Monitor Bank 2 Sensor 2",0,1.275,true));
//		pid_map.put(0x107, new PID_Entry(0x107,"O2 Sensor Monitor Bank 2 Sensor 3",0,1.275,true));
//		pid_map.put(0x108, new PID_Entry(0x108,"O2 Sensor Monitor Bank 2 Sensor 4",0,1.275,true));
//		pid_map.put(0x109, new PID_Entry(0x109,"O2 Sensor Monitor Bank 3 Sensor 1",0,1.275,true));
//		pid_map.put(0x010A, new PID_Entry(0x010A,"O2 Sensor Monitor Bank 3 Sensor 2",0,1.275,true));
//		pid_map.put(0x010B, new PID_Entry(0x010B,"O2 Sensor Monitor Bank 3 Sensor 3",0,1.275,true));
//		pid_map.put(0x010C, new PID_Entry(0x010C,"O2 Sensor Monitor Bank 3 Sensor 4",0,1.275,true));
//		pid_map.put(0x010D, new PID_Entry(0x010D,"O2 Sensor Monitor Bank 4 Sensor 1",0,1.275,true));
//		pid_map.put(0x010E, new PID_Entry(0x010E,"O2 Sensor Monitor Bank 4 Sensor 2",0,1.275,true));
//		pid_map.put(0x010F, new PID_Entry(0x010F,"O2 Sensor Monitor Bank 4 Sensor 3",0,1.275,true));
//		pid_map.put(0x110, new PID_Entry(0x110,"O2 Sensor Monitor Bank 4 Sensor 4",0,1.275,true));
//		pid_map.put(0x201, new PID_Entry(0x201,"O2 Sensor Monitor Bank 1 Sensor 1",0,1.275,true));
//		pid_map.put(0x202, new PID_Entry(0x202,"O2 Sensor Monitor Bank 1 Sensor 2",0,1.275,true));
//		pid_map.put(0x203, new PID_Entry(0x203,"O2 Sensor Monitor Bank 1 Sensor 3",0,1.275,true));
//		pid_map.put(0x204, new PID_Entry(0x204,"O2 Sensor Monitor Bank 1 Sensor 4",0,1.275,true));
//		pid_map.put(0x205, new PID_Entry(0x205,"O2 Sensor Monitor Bank 2 Sensor 1",0,1.275,true));
//		pid_map.put(0x206, new PID_Entry(0x206,"O2 Sensor Monitor Bank 2 Sensor 2",0,1.275,true));
//		pid_map.put(0x207, new PID_Entry(0x207,"O2 Sensor Monitor Bank 2 Sensor 3",0,1.275,true));
//		pid_map.put(0x208, new PID_Entry(0x208,"O2 Sensor Monitor Bank 2 Sensor 4",0,1.275,true));
//		pid_map.put(0x209, new PID_Entry(0x209,"O2 Sensor Monitor Bank 3 Sensor 1",0,1.275,true));
//		pid_map.put(0x020A, new PID_Entry(0x020A,"O2 Sensor Monitor Bank 3 Sensor 2",0,1.275,true));
//		pid_map.put(0x020B, new PID_Entry(0x020B,"O2 Sensor Monitor Bank 3 Sensor 3",0,1.275,true));
//		pid_map.put(0x020C, new PID_Entry(0x020C,"O2 Sensor Monitor Bank 3 Sensor 4",0,1.275,true));
//		pid_map.put(0x020D, new PID_Entry(0x020D,"O2 Sensor Monitor Bank 4 Sensor 1",0,1.275,true));
//		pid_map.put(0x020E, new PID_Entry(0x020E,"O2 Sensor Monitor Bank 4 Sensor 2",0,1.275,true));
//		pid_map.put(0x020F, new PID_Entry(0x020F,"O2 Sensor Monitor Bank 4 Sensor 3",0,1.275,true));
//		pid_map.put(0x210, new PID_Entry(0x210,"O2 Sensor Monitor Bank 4 Sensor 4",0,1.275,true));
//		pid_map.put(0x0, new PID_Entry(0x0,"mode 9 supported PIDs 01 to 20",-1,-1,false));
//		pid_map.put(0x1, new PID_Entry(0x1,"VIN Message Count in command 09 02",-1,-1,false));
//		pid_map.put(0x2, new PID_Entry(0x2,"Vehicle identification number (VIN)",-1,-1,false));
//		pid_map.put(0x4, new PID_Entry(0x4,"calibration ID",-1,-1,false));
//		pid_map.put(0x6, new PID_Entry(0x6,"calibration",-1,-1,false));

	}
	
	/*
	 * Wikipedia link: http://en.wikipedia.org/wiki/OBD-II_PIDs
	 */
	
	
	/*Convert using the formulas*/
	public double get_real_value(String msg){
		int pid_int = Integer.parseInt(msg.substring(2,4),16);
		switch(pid_int){
		//0x00-0x03 are bit encoded and have not been added yet
		//0x04-0x10 have been added
			case(0x03):
				//Bit encoded
				return -1;
			case(0x04):
				return getA(msg)*((double)100/(double)255);
			case(0x05):
				return (getA(msg) - 40);
			case(0x0A):
				return (getA(msg)*3);
			case(0x0B):
				return getA(msg);
			case(0x0C):
				return (((getA(msg) * (double)256) + getB(msg)) / (double)4);
			case(0x0D):
				return getA(msg);
			case(0x0E):
				return (getA(msg)/(double)2 - (double)64);
			case(0x0F):
				return (getA(msg)-40);
			case(0x10):
				return (((getA(msg) * (double)256) + getB(msg)) / (double)100);
			case(0x11):
				return getA(msg)*((double)100/(double)255);	
			case(0x12):
				//Bit encoded
				return -1;
			case(0x13):
				//[A0..A3] == Bank 1, Sensors 1-4. [A4..A7] == Bank 2...
				return -1;
			case(0x1C):
				//Bit encoded
				return -1;
			case(0x1D):
				//Similar to PID 13, but [A0..A7] == [B1S1, B1S2, B2S1, B2S2, B3S1, B3S2, B4S1, B4S2]
				return -1;
			case(0x1E):
				//A0 == Power Take Off (PTO) status (1 == active)   [A1..A7] not used
				return -1;
			case(0x1F):
				return ((getA(msg)*256)+getB(msg));
			case(0x22):
				return (((getA(msg)*256)+getB(msg))*0.079);
			case(0x23):
				return (((getA(msg)*256)+getB(msg))*10);
			case(0x2C):
				return getA(msg)*((double)100/(double)255);
			case(0x2D):
				return (getA(msg)-(double)128)*((double)100/(double)128);
			case(0x2E):
				return getA(msg)*((double)100/(double)255);
			case(0x2F):
				return getA(msg)*((double)100/(double)255);
			case(0x31):
				return ((getA(msg)*256)+getB(msg));
			case(0x32):
				return (((getA(msg)*(double)256)+getB(msg))/(double)4);
			case(0x33):
				return getA(msg);
			case(0x41):
				//Bit encoded
				return -1;
			case(0x42):
				return (((getA(msg)*(double)256)+getB(msg))/(double)1000);
			case(0x43):
				return ((getA(msg)*(double)256)+getB(msg))*((double)100/(double)255);
			case(0x44):
				return (((getA(msg)*(double)256)+getB(msg))/(double)31768);
			case(0x45):
				return getA(msg)*((double)100/(double)255);
			case(0x46):
				return (getA(msg)-40);
			case(0x47):
				return getA(msg)*((double)100/(double)255);
			case(0x48):
				return getA(msg)*((double)100/(double)255);
			case(0x49):
				return getA(msg)*((double)100/(double)255);
			case(0x4A):
				return getA(msg)*((double)100/(double)255);
			case(0x4B):
				return getA(msg)*((double)100/(double)255);
			case(0x4C):
				return getA(msg)*((double)100/(double)255);
			case(0x4E):
				return ((getA(msg)*256)+getB(msg));
			case(0x50):
				//A*10, B, C, and D are reserved for future use
				return -1;
			case(0x51):
				//From fuel type table
				return -1;
			case(0x52):
				return getA(msg)*((double)100/(double)255);
			case(0x53):
				return (((getA(msg)*(double)256)+getB(msg))/(double)200);
			case(0x54):
				return (((getA(msg)*256)+getB(msg))-32767);
			case(0x59):
				return (((getA(msg)*256)+getB(msg))*10);
			case(0x5A):
				return getA(msg)*((double)100/(double)255);
			case(0x5B):
				return getA(msg)*((double)100/(double)255);
			case(0x5C):
				return (getA(msg)-40);
			case(0x5D):
				return ((((getA(msg)*(double)256)+getB(msg))-(double)26880)/(double)128);
			case(0x5E):
				return (((getA(msg)*256)+getB(msg))*0.05);
			case(0x5F):
				//Bit Encoded
				return -1;
			case(0x61):
				return (getA(msg)-125);
			case(0x62):
				return (getA(msg)-125);
			case(0x63):
				return (getA(msg)*256 + getB(msg));
			case(0x64):
				/*
				 * 	A-125 Idle
					B-125 Engine point 1
					C-125 Engine point 2
					D-125 Engine point 3
					E-125 Engine point 4
				 * */
				return -1;
			case(0x66):
				//blank
				return -1;
			case(0x67):
				//blank
				return -1;
			case(0x68):
				//blank
				return -1;
			case(0x6D):
				//blank
				return -1;
			case(0x6E):
				//blank
				return -1;
			case(0x70):
				//blank
				return -1;
			case(0x72):
				//blank
				return -1;
			case(0x73):
				//blank
				return -1;
			case(0x74):
				//blank
				return -1;
			case(0x75):
				//blank
				return -1;
			case(0x7F):
				//blank
				return -1;
			case(0x86):
				//blank
				return -1;
			case(0x87):
				//blank
				return -1;
			
		}
		return 0;
	}

	
	public String get_label(String pid){
		int pid_int = Integer.parseInt(pid,16);
		return pid_map.get(pid_int).getLabel();
	}
	
	public boolean getDynamic(String pid){
		int pid_int = Integer.parseInt(pid,16);
		return pid_map.get(pid_int).getDynamic();
	}
	
	
	public double get_min_val(String pid){
		int pid_int = Integer.parseInt(pid,16);
		return pid_map.get(pid_int).getMin();
	}
	
	
	public double get_max_val(String pid){
		int pid_int = Integer.parseInt(pid,16);
		return pid_map.get(pid_int).getMax();
	}
	
	public String get_unit(String pid){
		int pid_int = Integer.parseInt(pid,16);
		return pid_map.get(pid_int).getUnit();
	}
//	String[] get_pid_list(){
//		return gauge_labels;
//	}
	
	/*Helper methods*/
	
	private int  getA(String msg){
		return Integer.parseInt(msg.substring(4,6),16);
		
	}
	private int getB(String msg){
		return Integer.parseInt(msg.substring(6,8),16);
	}
	
	private int getC(String msg){
		return Integer.parseInt(msg.substring(8,10),16);
	}
	
	private int getD(String msg){
		return Integer.parseInt(msg.substring(10,12),16);
	}
}


